package com.app.utils.impl.labour;

import android.os.Build;

import androidx.annotation.RequiresApi;

import com.app.utils.impl.IConsole;
import com.app.utils.impl.Strategy;
import com.zndroid.utils.XUtils;
import com.zndroid.utils.impl.TimeUtil;

import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;
import java.util.Locale;

/**
 * Created by lzy on 2022/2/21.
 */
public class TimerUtilStrategy extends Strategy {
    public TimerUtilStrategy(IConsole iConsole) {
        super(iConsole);
    }

    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    public void doing() {
        TimeUtil util = XUtils.create().timeUtil();

        iConsole.console("isLeapYear(‘2004’)", util.isLeapYear(2004) + "");
        iConsole.console("isLeapYear(‘2022’)", util.isLeapYear(2022) + "");
        iConsole.console("isNowInTimeArea(‘2018-12-25 07:34:39 ~ 2022-02-24 17:21:19’)", util.isNowInTimeArea(util.getTimeDetail(1545694479618L), util.getTimeDetail(1645694479618L)) + "");
        iConsole.console("ms2HMS(‘80’)", util.second2HMS(80));
        iConsole.console("getTime(‘now’)", util.getTime(Date.from(Instant.now())));
        iConsole.console("getFormatTime(‘HH-mm-ss’)", util.getFormatDateTime(Date.from(Instant.now()), "HH-mm-ss"));
        iConsole.console("getDate(‘now’)", util.getDate());
        iConsole.console("getFormatTime(‘yyyy-MM-dd’)", util.getFormatDateTime(new Date(), "yyyy-MM-dd"));
        iConsole.console("formatTime(‘525346’)", util.formatTime(525346));
        iConsole.console("formatTime(‘525346, 英文格式’)", util.formatTime(525346, false));
        iConsole.console("getHoroscope(‘now’)", util.getHoroscope(new Date()));
        iConsole.console("getFullTime(‘now’)", util.getFullTime());
        iConsole.console("getWholeTime(‘now’)", util.getWholeTime());
        iConsole.console("getBetween(‘2018-12-25 07:34:39 ~ 2022-02-24 17:21:19’)", util.getBetween(new SimpleDateFormat("MM-dd HH:mm:ss:sss", Locale.getDefault()), 1545694479618L, 1645694479618L) + "s");
        iConsole.console("getSmartDate(‘1645495027629L’)", util.getSmartDate(new Date(1645495027629L)));
        iConsole.console("getSmartBirthday(‘1645495027629L’)", util.getSmartBirthday(1645495027629L, false));
    }
}
